import service from '@/utils/requestTopo';

/**
 * 获取所有一二级节点（通用）
 * @returns {*}
 */
export const getVmNodeAllApi = () =>
  service({
    url: `/simulation/res/computer/tree/`,
    method: 'get',
  });

/**
 * 获取计算节点下虚拟机（树）
 * @returns {*}
 */
export const getVmNodeToVmApi = (id, params) =>
  service({
    url: `/simulation/res/computer/${id}/vpcList/`,
    method: 'get',
    params,
  });

/**
 * 查询集群-VPC列表
 * @param id
 * @param params
 * @returns {*}
 */
export const getVpcListByClusterApi = (id, params) =>
  service({
    url: `/simulation/res/cluster/${id}/vpcDetailList/`,
    method: 'get',
    params,
  });

/**
 * 查询计算节点-VPC列表
 * @param id
 * @param params
 * @returns {*}
 */
export const getVPCListByComputedApi = (id, params) =>
  service({
    url: `/simulation/res/computer/${id}/vpcDetailList/`,
    method: 'get',
    params,
  });

/**
 * 新增VPC网络
 * @param data
 * @returns {*}
 */
export const addVPCApi = data =>
  service({
    url: '/simulation/res/vpc/',
    method: 'post',
    data,
  });

/**
 * 编辑VPC网络
 * @param id
 * @param data
 * @returns {*}
 */
export const editVPCApi = (id, data) =>
  service({
    url: `/simulation/res/vpc/${id}/`,
    method: 'put',
    data,
  });

/**
 * VPC生成
 * @param id
 * @returns {*}
 */
export const generateVPCApi = id =>
  service({
    url: `/simulation/res/vpc/${id}/generate/`,
    method: 'post',
  });

/**
 * 删除VPC
 * @param id
 * @returns {*}
 */
export const delVPCApi = id =>
  service({
    url: `/simulation/res/vpc/${id}/`,
    method: 'delete',
  });

/**
 * 获取vpc详情数据
 * @param id
 * @returns {*}
 */
export const getVPCDetailApi = id =>
  service({
    url: `/simulation/res/vpc/${id}/`,
    method: 'get',
  });

/**
 * 生效路由表列表
 * @param id
 * @param params
 * @returns {*}
 */
export const getEffectRouterByVPCApi = (id, params) =>
  service({
    url: `/simulation/res/vpc/${id}/route/`,
    method: 'get',
    params,
  });

/**
 * 路由配置列表
 * @param id
 * @param params
 * @returns {*}
 */
export const getRouterConfigByVPCApi = (id, params) =>
  service({
    url: `/simulation/res/vpc/${id}/staticRoute/`,
    method: 'get',
    params,
  });

/**
 * 删除路由配置
 * @param id
 * @param rID
 * @returns {*}
 */
export const delRouterConfigByVPCApi = (id, rID) =>
  service({
    url: `/simulation/res/vpc/${id}/staticRoute/${rID}/`,
    method: 'delete',
  });

/**
 * 新建路由配置
 * @param id
 * @param data
 * @returns {*}
 */
export const addRouterConfigByVPCApi = (id, data) =>
  service({
    url: `/simulation/res/vpc/${id}/staticRoute/`,
    method: 'post',
    data,
  });

/**
 * 新增防火墙（访问控制）-防火墙
 * @param id
 * @param data
 * @returns {*}
 */
export const addAccessControlByVPCApi = (id, data) =>
  service({
    url: `/simulation/res/vpc/${id}/firewall/`,
    method: 'post',
    data,
  });

/**
 * 删除防火墙（访问控制）-防火墙
 * @param id
 * @param rID
 * @returns {*}
 */
export const delAccessControlByVPCApi = (id, rID) =>
  service({
    url: `/simulation/res/vpc/${id}/firewall/${rID}/`,
    method: 'delete',
  });

/**
 * 修改防火墙（访问控制）-防火墙
 * @param id
 * @param rID
 * @param data
 * @param params
 * @returns {*}
 */
export const editAccessControlByVPCApi = (id, rID, data, params) =>
  service({
    url: `/simulation/res/vpc/${id}/firewall/${rID}/`,
    method: 'put',
    data,
    params,
  });

/**
 * 查询防火墙（访问控制）列表-防火墙
 * @param id
 * @param params
 * @returns {*}
 */
export const getAccessControlByVPCApi = (id, params) =>
  service({
    url: `/simulation/res/vpc/${id}/firewall/`,
    method: 'get',
    params,
  });

/**
 * 新增源Nat-防火墙
 * @param id
 * @param data
 * @returns {*}
 */
export const addSourceNatByVPCApi = (id, data) =>
  service({
    url: `/simulation/res/vpc/${id}/snat/`,
    method: 'post',
    data,
  });

/**
 * 删除源Nat-防火墙
 * @param id
 * @param rID
 * @returns {*}
 */
export const delSourceNatByVPCApi = (id, rID) =>
  service({
    url: `/simulation/res/vpc/${id}/snat/${rID}/`,
    method: 'delete',
  });

/**
 * 修改源Nat-防火墙
 * @param id
 * @param rID
 * @param data
 * @param params
 * @returns {*}
 */
export const editSourceNatByVPCApi = (id, rID, data, params) =>
  service({
    url: `/simulation/res/vpc/${id}/snat/${rID}/`,
    method: 'put',
    data,
    params,
  });

/**
 * 源Nat列表-防火墙
 * @param id
 * @param params
 * @returns {*}
 */
export const getSourceNatByVPCApi = (id, params) =>
  service({
    url: `/simulation/res/vpc/${id}/snat/`,
    method: 'get',
    params,
  });

/**
 * 新增端口映射-防火墙
 * @param id
 * @param data
 * @returns {*}
 */
export const addPortMappingByVPCApi = (id, data) =>
  service({
    url: `/simulation/res/vpc/${id}/portmap/`,
    method: 'post',
    data,
  });

/**
 * 删除端口映射-防火墙
 * @param id
 * @param rID
 * @returns {*}
 */
export const delPortMappingByVPCApi = (id, rID) =>
  service({
    url: `/simulation/res/vpc/${id}/portmap/${rID}/`,
    method: 'delete',
  });

/**
 * 修改端口映射-防火墙
 * @param id
 * @param rID
 * @param data
 * @param params
 * @returns {*}
 */
export const editPortMappingByVPCApi = (id, rID, data, params) =>
  service({
    url: `/simulation/res/vpc/${id}/portmap/${rID}/`,
    method: 'put',
    data,
    params,
  });

/**
 * 端口映射列表-防火墙
 * @param id
 * @param params
 * @returns {*}
 */
export const getPortMappingByVPCApi = (id, params) =>
  service({
    url: `/simulation/res/vpc/${id}/portmap/`,
    method: 'get',
    params,
  });

/**
 * 新增入站策略-防火墙
 * @param id
 * @param data
 * @returns {*}
 */
export const addInboundStrategyByVPCApi = (id, data) =>
  service({
    url: `/simulation/res/vpc/${id}/inbound/`,
    method: 'post',
    data,
  });

/**
 * 删除入站策略-防火墙
 * @param id
 * @param rID
 * @returns {*}
 */
export const delInboundStrategyByVPCApi = (id, rID) =>
  service({
    url: `/simulation/res/vpc/${id}/inbound/${rID}/`,
    method: 'delete',
  });

/**
 * 修改入站策略-防火墙
 * @param id
 * @param rID
 * @param data
 * @param params
 * @returns {*}
 */
export const editInboundStrategyByVPCApi = (id, rID, data, params) =>
  service({
    url: `/simulation/res/vpc/${id}/inbound/${rID}/`,
    method: 'put',
    data,
    params,
  });

/**
 * 入站策略列表-防火墙
 * @param id
 * @param params
 * @returns {*}
 */
export const getInboundStrategyByVPCApi = (id, params) =>
  service({
    url: `/simulation/res/vpc/${id}/inbound/`,
    method: 'get',
    params,
  });

/**
 * 新增DHCP
 * @param id
 * @param data
 * @returns {*}
 */
export const addDHCPByVPCApi = (id, data) =>
  service({
    url: `/simulation/res/vpc/${id}/dhcp/`,
    method: 'post',
    data,
  });

/**
 * 删除DHCP
 * @param id
 * @param data
 * @returns {*}
 */
export const delDHCPByVPCApi = (id, data) =>
  service({
    url: `/simulation/res/vpc/${id}/dhcp/`,
    method: 'delete',
    data,
  });

/**
 * 新增接口配置（网卡）
 * @param id
 * @param data
 * @returns {*}
 */
export const addApiConfigByVPCApi = (id, data) =>
  service({
    url: `/simulation/res/vpc/${id}/port/`,
    method: 'post',
    data,
  });

/**
 * 删除接口配置（网卡）
 * @param id
 * @param rID
 * @returns {*}
 */
export const delApiConfigByVPCApi = (id, rID) =>
  service({
    url: `/simulation/res/vpc/${id}/port/${rID}/`,
    method: 'delete',
  });

/**
 * 修改接口配置（网卡）
 * @param id
 * @param rID
 * @param data
 * @returns {*}
 */
export const editApiConfigByVPCApi = (id, rID, data) =>
  service({
    url: `/simulation/res/vpc/${id}/port/${rID}/`,
    method: 'put',
    data,
  });

/**
 * 批量操作（启动、停止）
 * @param data
 * @returns {*}
 */
export const batchOptionByVPCApi = data =>
  service({
    url: `/simulation/res/vpc/operation/`,
    method: 'post',
    data,
  });

/**
 * 获取端口
 * @param id
 * @returns {*}
 */
export const getPortByVPCApi = id =>
  service({
    url: `/simulation/res/vpc/${id}/port/`,
    method: 'get',
  });

/**
 * 获取dhcp
 * @param id
 * @returns {*}
 */
export const getDHCPByVPCApi = id =>
  service({
    url: `/simulation/res/vpc/${id}/dhcp/`,
    method: 'get',
  });

/**
 * 获取树下节点（包含展开懒加载、搜索筛选、滚动加载）
 * @param params
 * @returns {*}
 */
export const getNodeTreeApi = params =>
  service({
    url: `/simulation/res/computer/vpcList/`,
    method: 'get',
    params,
  });

/**
 * 删除VPC（批量、单个）
 * @param data
 * @returns {*}
 */
export const delVPCBatchApi = data =>
  service({
    url: `/simulation/res/vpc/`,
    method: 'delete',
    data,
  });

/**
 * 获取场景里DHCP
 * @param {*} id
 * @param {*} rid
 * @param {*} data
 * @returns
 */
export const getDHCPConfigApi = (id, rid, params) =>
  service({
    url: `/simulation/scene/scene/${id}/instance/${rid}/dhcp/`,
    method: 'get',
    params,
  });

/**
 * 场景里操作DHCP
 * @param {*} id
 * @param {*} rid
 * @param {*} data
 * @returns
 */
export const addDHCPConfigApi = (id, rid, data) =>
  service({
    url: `/simulation/scene/scene/${id}/instance/${rid}/dhcp/`,
    method: 'post',
    data,
  });

/**
 * 删除场景里DHCP
 * @returns
 */
export const delDHCPConfigApi = (id, rid, dhcpid) =>
  service({
    url: `/simulation/scene/scene/${id}/instance/${rid}/dhcp/${dhcpid}/`,
    method: 'delete',
  });
